<template>
<div>
  <el-tabs v-model="show" type="card" @tab-click="handleClick" >
    <el-tab-pane label="重设密码管理" name="first" >
      <el-table
        :data="employee_request"
        :row-style="{height: '0'}"
        :cell-style="{padding: '0'}"
        style="width: 100%"
        @row-click="getDetails"
        id="out-tableforjob"
      >
        <el-table-column align="center" prop="userId" label="员工Id" width="75"></el-table-column>
        <el-table-column align="center" prop="requestoftype" label="请求类型" width="100"></el-table-column>
        <el-table-column align="center" prop="checkcode" label="提取码" width="120"></el-table-column>
        <el-table-column align="center" prop="isavailable" label="是否处理0/1" width="80"></el-table-column>
        <el-table-column align="center" prop="requestcode" label="重设密码" width="400"></el-table-column>
        <el-table-column fixed="right" width="400" label="操作" id="work">
          <template slot-scope="scope">
            <!--                  <el-button v-show="scope.row.role == 'user'&&scope.row.iswork==`0`" @click="addNewDeper(scope.row)"style="padding: 3px" size="mini" type="success">添加部门成员</el-button>-->
            <!--                  <el-button v-show="scope.row.role =='user'&&scope.row.iswork==`1`" @click="openshowDeper(scope.row)"style="padding: 3px" size="mini" type="primary">查看所属部长</el-button>-->
            <!--                  <el-button v-show="scope.row.role =='department'" @click="changeNewDeper(scope.row)"style="padding: 3px" size="mini" type="warning">更换部门部长</el-button>-->
            <!--                  -->
            <el-button v-show="scope.row.isavailable==1" @click="ResetAndSendEmail(scope.row)" style="padding: 3px" size="mini" type="primary">重设密码并发送至邮箱</el-button>
            <el-button v-show="scope.row.isavailable==1" @click="refuseRequest(scope.row)"style="padding: 3px" size="mini" type="warning">取消申请</el-button>
          </template>
        </el-table-column>
      </el-table>

    </el-tab-pane>
      <el-tab-pane label="权限管理（因为没时间做树形菜单所以弄了个简单的点击触发拦截.png）" name="second" >
      </el-tab-pane>
  </el-tabs>

</div>
</template>

<script>
    export default {
        name: "SystemManagement",
      data()
      {
        return{
          employee_request:[],
          employee_requests:{
            userId:"",
            requestoftype:"",
            checkcode:"",
            isavailable:"",
            requestcode:"",
          },
          show:"first",

        }
      },
      mounted() {
        this.selectAllrequest()
      },
      methods:{
        handleClick(tab, event) {
          if (tab.index == 0) {
            // alert("啦啦啦")

          } else if (tab.index == 1) {

            alert("施工中或咕咕咕")
          }
        },
        ResetAndSendEmail(data)
        {
        //  alert(JSON.stringify(data))
          this.$axios.post("/updateResetEmpRequestCode",{
            userId:data.userId,
            requestoftype:data.requestoftype,
            checkcode:data.checkcode,
            isavailable: data.isavailable,
            requestcode:data.requestcode,
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("请求失败！")
          }).finally(()=>{
            this.selectAllrequest()
          })
        },
        refuseRequest(data)
        {
          this.$axios.post("/deletepasswordrequestById",{
            userId:data.userId
          }).then((res)=>{
            this.$message.success(res.data.msg)
          }).catch(()=>{
            this.$message.error("删除失败！")
          }).finally(()=>{
            this.selectAllrequest()
          })
        },
        selectAllrequest()
        {
          this.$axios.post("/selectAllEmployee_request",{

          }).then((res)=>{
            this.employee_request =res.data
          })
        },
      }
    }
</script>

<style scoped>

</style>
